<?php
namespace App\Http\Controllers;
use Log;
use Symfony\Component\HttpFoundation\RequestMatcher;
use Illuminate\Http\Request;

class WechatController extends Controller
{


    /*
     * js获取微信的信息
     */
    public function getWechatInfo( )
    {
//        $url = $request->get('url');
//        $res = file_get_contents('https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx9d1e451eab846f3d&secret=4cad6f43f1b2fb2cfd90e908185c0c4e');
//        $res = json_decode($res, true);
//        $token = $res['access_token'];
//        $url2 = sprintf("https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=%s&type=jsapi", $token);
//        $re = file_get_contents($url2);
//        $re = json_decode($re, true);
        $url = 'http://mp.weixin.qq.com?params=value';
        $timestamp = time();
        $nonceStr = "sakura";
        $ticket = 'kgt8ON7yVITDhtdwci0qeYDDK1tRRMd0SlVdC3PFhtMv198qZijtHLUFrJLLak37lOW4ZWoOvd0jP0jEKaO5gA';
        $wxOri = sprintf("jsapi_ticket=%s&noncestr=%s&timestamp=%s&url=%s", $ticket, $nonceStr, $timestamp,$url);
        $wxSha1 = sha1($wxOri);
        $result['appId'] = 'wx9d1e451eab846f3d';
        $result['timestamp'] = $timestamp;
        $result['nonceStr'] = $nonceStr;
        $result['signature'] = $wxSha1;
        return response()->json(['msg' => 1, 'data' => $result]);
    }



}